package main

import (
	AdminRouters "go-management-system/routers/admin"
	"os"

	"github.com/gin-gonic/gin"
	"github.com/go-ini/ini"
)

func main() {
    _ = os.Setenv("GIN_MODE", "release")
    //加载配置
    cfg, err := ini.Load("./conf/api.ini")
    if err != nil {
        //fmt.Printf("Fail to read file: %v", err)
        os.Exit(1)
    }

    // 运行模式
    mode := cfg.Section("").Key("app_mode").String()

    if mode == "develop" {
        gin.SetMode(gin.DebugMode)
    } else {
        gin.SetMode(gin.ReleaseMode)
    }

    // 注册路由
    r := AdminRouters.Register()
    r.LoadHTMLGlob("templates/*.html")
    r.LoadHTMLGlob("templates/admin/*.html")
    // r.LoadHTMLGlob("templates/**/**")
    http_port := cfg.Section("").Key("http_port").String()
    //r := gin.Default()

    r.Run(http_port)
}
